
package com.remoteblogger.wordpress;

import java.util.ArrayList;
import java.util.List;
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;

/*
 * WordPress user object.
 * @author  Prasath Nadarajah
 * 
 */
public class WPGlobalUser {

    static private WPGlobalUser globalUser;

    private List<WPClient> client;

    private  WPGlobalUser() {
        // initialising with 10 blogs
        client = new ArrayList<WPClient>();
    }

    static public WPGlobalUser getInstance() {
        if (globalUser == null)
            // must implement for reading from file object
            globalUser = new WPGlobalUser();
        return globalUser;
    }


    public List<WPClient> getClient() {
        return client;
    }

    public boolean addClient(String uname, String pword, String blogURL) {
        // this will retrun true/false must configure to give user feedback
        // multiple dialogs may appear however we must cathc every return boolean value
        if(client.add(new WPClient(uname, pword, pword))) {
            //if this is successfull display it in final method
        } else {
            // this will happen less likely
            NotifyDescriptor d = new NotifyDescriptor.Message("Error in adding new Weblog");
            DialogDisplayer.getDefault().notify(d);
        }
        return true;
    }

}
